package com.imooc.controller;

import com.imooc.domain.Demo;
import com.imooc.properties.MyGirl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

/**
 * Created by ancy on 2017/7/4.
 */
@RestController
public class HelloController {

    @Value("${age}")
    private Integer age;
    @Value("${cupSize}")
    private String cup;

    @Value("${content}")
    private  String content;

    @Autowired
    private MyGirl girl;


    @RequestMapping(value = "/hello" , method = RequestMethod.GET)
    public  String say(){

        System.out.println(girl.getCupSize() + girl.getAge());

        System.out.println(cup);
        return age.toString() + cup + content;
    }

    @GetMapping(value = "/getDemo")
    public Demo getDemo () {

        Demo  demo = new Demo();
        demo.setCreateTime(new Date(System.currentTimeMillis()));
        demo.setName("zssss");
        demo.setId(001001);
        return  demo;
    }

    @GetMapping(value = "/getDemo01")
    public Demo getDemo01 () {

        Demo  demo = new Demo();
        demo.setCreateTime(new Date(System.currentTimeMillis()));
        demo.setId(1000);
        return  demo;
    }
}
